package org.jschlicht.scalaml.ast

/* PROGRAMS AND MODULES */
// Program
case class Program(topDecs: List[TopDec])

// Top level Declaration
abstract class TopDec
abstract class Expr extends TopDec
abstract class ObjectDec extends TopDec
//case class SigDec(parts: List[SigDecPart])
//abstract class FunctorDec extends TopDec // TODO: should not be abstract

// Object Declaration
abstract class Dec extends ObjectDec
//case class StructDecPart(id: String, constraint: Option[SigConstraint], structure: Structure)
//case class StructDec(parts: List[StructDecPart]) extends ObjectDec
case class LocalDec(dec: ObjectDec, inDec: ObjectDec) extends ObjectDec

// Signature Declaration
//case class SigDecPart(id: String, signature: Signature)


// Sig Constraint
// TODO: Differentiate between operators : and :>
//case class SigConstraint(signature: Signature)

// Functor Declaration

// FunctorBinding

// Structure

// Signature

// Specification

/* DECLARATIONS */
// Declaration
case class ValDec(name: String, valType: String, expression: Expr) extends Dec // does not handle AND keyword

// Function Heading

// Type Binding

// Datatype Binding

// Type Var List

/* EXPRESSIONS */
// Expression
abstract class InfixExpr extends Expr
case class TypedExpr(expr: Expr, exprType: String) extends Expr
case class AndAlsoExpr(lhs: Expr, rhs: Expr) extends Expr
case class OrElseExpr(lhs: Expr, rhs: Expr) extends Expr
case class HandleExpr(expr: Expr, patternMatch: PatternMatch) extends Expr
case class RaiseExpr(expr: Expr) extends Expr
case class IfExpr(predicate: Expr, ifBody: Expr, elseBody: Expr) extends Expr
case class WhileExpr(predicate: Expr, body: Expr) extends Expr
case class CaseExpr(expr: Expr, patternMatch: PatternMatch) extends Expr
case class FnExpr(patternMatch: PatternMatch) extends Expr

// Infix Expression
case class AtomicExprs(exprs:List[AtomicExpr]) extends InfixExpr
case class InfixApp(lhs:InfixExpr, op: String, rhs: InfixExpr) extends InfixExpr

// Atomic Expression
abstract class AtomicExpr extends Expr
abstract class CompoundNameExpr extends AtomicExpr
abstract class ConstantExpr extends AtomicExpr
abstract class TupleExpr extends AtomicExpr
abstract class ListExpr extends AtomicExpr
abstract class RecordExpr extends AtomicExpr
abstract class TupleAccessExpr extends AtomicExpr
abstract class ParenExpr extends AtomicExpr
abstract class LetExpr extends AtomicExpr

/* MATCHES AND PATTERNS */
// Match
case class PatternMatches(patternMatches: List[PatternMatch])
case class PatternMatch(pattern: Pattern, expr: Expr)

// Pattern
abstract class Pattern
abstract class AtomicPattern extends Pattern
abstract class QualifiedPattern extends Pattern // Compound Name ~ Atomic Pattern
abstract class InfixOpPattern extends Pattern
abstract class TypedPattern extends Pattern
abstract class AsPattern extends Pattern

// Atomic Pattern
case class UnderscorePattern() extends AtomicPattern
case class CompoundNamePattern(compoundName: String) extends AtomicPattern
case class ConstantPattern(constant: ConstExpr) extends AtomicPattern
case class TuplePattern(patterns: List[Pattern]) extends AtomicPattern
case class ListPattern(patterns: List[Pattern]) extends AtomicPattern
abstract class RecordPattern extends AtomicExpr

/* TYPES */
// Type
case class Type(t: String)
//case class SimpleTypeVar extends Type
// ???
//case class TupleType(types: List[Type]) extends Type
//case class FunctionType(domain: Type, range: Type) extends Type
//case class RecordType(types: Map[String,Type]) extends Type
//case class ParenType(t: Type) extends Type

/* LEXICAL: IDENTIFIERS, CONSTANTS, COMMENTS */
// Compound Ident
case class IdentCompoundName(id: String)
case class InfixOpCompoundName(op: String)

// Compound Name
abstract class Name
case class NameID(id: String)
case class InfixOpName(op: String)

// Constant
abstract class ConstExpr extends Expr
case class IntConst(value: Int) extends ConstExpr
case class RealConst(value: Double) extends ConstExpr
case class CharConst(value: Char) extends ConstExpr
case class StringConst(value: String) extends ConstExpr